import requests
import json
import os
import urllib.request
#页数
for i in range(0,272):
    img = ''
    # mysql url = 'https://vip.ow365.cn/PW/GetPage?f=YXR0YWNobWVudC1jZW50ZXIuYm94dWVndS5jb20uODBcMzE5YzVjMDA2OGJjNDIwY2JhZWYwZmFiMGU2ODBkNjUucGRm&img='+img+'&isMobile=false&vid=iC4lxdn2UAQeuT4Pl1iBkQ==&dk=0&ver=2&sn='+str(i)
    #java url = 'https://vip.ow365.cn/PW/GetPage?f=YXR0YWNobWVudC1jZW50ZXIuYm94dWVndS5jb20uODBcMGVmNGJiYzFkNTRkNDNjMzhkYTg5NzZkMzM2ZTg2YmEucGRm&img='+img+'&isMobile=false&vid=hH2RktznuaooUM2ZnFfiDA==&dk=0&ver=2&sn='+str(i)
    # linux url = 'https://vip.ow365.cn/PW/GetPage?f=YXR0YWNobWVudC1jZW50ZXIuYm94dWVndS5jb20uODBcYjg2ZjE2ZTE2MzcxNDJhZDk4NjE4YjJmYTVlOTlkYTEucGRm&img='+img+'&isMobile=false&vid=WCtZFof0nYjigNaVmG1faQ==&dk=0&ver=2&sn='+str(i)
    #css url = 'https://vip.ow365.cn/PW/GetPage?f=YXR0YWNobWVudC1jZW50ZXIuYm94dWVndS5jb20uODBcNWZiYWQ3ZDhjZWU1NDJjYmFiNTIxOTQ5MTQ2ZDUxMTIucGRm&img='+img+'&isMobile=false&vid=6fa0rLCcfNRhZL6jkAVxSg==&dk=0&ver=2&sn='+str(i)
    # 安卓url = 'https://vip.ow365.cn/PW/GetPage?f=YXR0YWNobWVudC1jZW50ZXIuYm94dWVndS5jb20uODBcZWMxMGU5MTM2YmIyNGRlNDg5YzY2Nzk4OGM1ODUxZDQucGRm&img='+img+'&isMobile=false&vid=EOsdx0lbE0ytwjDz9PCBuw==&dk=0&ver=2&sn='+str(i)
    url = 'https://vip.ow365.cn/PW/GetPage?f=YXR0YWNobWVudC1jZW50ZXIuYm94dWVndS5jb20uODBcNDc2NmE2ODQwNGMyNGM3YmIzZWQwMWUzNTdiODNjMjYucGRm&img='+img+'&isMobile=false&vid=XovcW4m5C0OBTwA578UMIQ==&dk=0&ver=2&sn='+str(i)
    headers = {
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3314.0 Safari/537.36 SE 2.X MetaSr 1.0',
        'referer': 'https://vip.ow365.cn/?i=11311&ssl=1&furl=0As6WW@zSHIfqZy_0miBI1NfVmqplNkx4osgxUapgos7zntvq_BluwUV5DjSGRhsHRFJwyGpvHi9cjUTIGzm3TpI3_@ANYJVnfRyutX6IWilrFkjz00GbDnEckFS4bAj5ycVJ82derjY2lGuBlNSCQ=='
    }
    r = requests.get(url,headers=headers)
    js = json.loads(r.text)
    id = js.get("NextPage")
    img = str(id)
    url1 = 'https://vip.ow365.cn/img?img='+str(id)+'&tp='
    #r1 = requests.get(url1, headers=headers)
    fliename = str(i) + ".png"
    name = r"D:\Temp\png"
    path = os.path.join(name, fliename)
    opener = urllib.request.build_opener()
    opener.addheaders = [('referer',
                          'https://vip.ow365.cn/?i=11311&ssl=1&furl=0As6WW@zSHIfqZy_0miBI1NfVmqplNkx4osgxUapgos7zntvq_BluwUV5DjSGRhsHRFJwyGpvHi9cjUTIGzm3TpI3_@ANYJVnfRyutX6IWilrFkjz00GbDnEckFS4bAj5ycVJ82derjY2lGuBlNSCQ==')]
    urllib.request.install_opener(opener)
    urllib.request.urlretrieve(url1, filename=path)
    print(url1)
